/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sistemabienes;

import com.sun.data.provider.impl.CachedRowSetDataProvider;
import com.sun.rave.web.ui.appbase.AbstractFragmentBean;
import com.sun.webui.jsf.component.CommonTask;
import com.sun.webui.jsf.component.CommonTasksGroup;
import com.sun.webui.jsf.model.DefaultTableDataProvider;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import java.util.Iterator;
import java.util.List;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;

/**
 * <p>Fragment bean that corresponds to a similarly named JSP page
 * fragment.  This class contains component definitions (and initialization
 * code) for all components that you have defined on this fragment, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @version menu.java
 * @version Created on 15-09-2010, 04:13:22 PM
 * @author luis
 */

public class menu extends AbstractFragmentBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization. <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
//         ufvDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.ufvRowSet}"));
        Iterator iter = this.getSessionBean1().getRoles().iterator();
        
         try{
     //   if(getLogueo()!=false || getLogueo()==null)
    //  {
        menRegAct.setVisible(false);
        menAsign.setVisible(false);
        menDevol.setVisible(false);
        menBaja.setVisible(false);
        menRevaluo.setVisible(false);
        menEncargados.setVisible(false);
        menActualiz.setVisible(false);
        menUfv.setVisible(false);
        menGruposC.setVisible(false);
        menReportes.setVisible(false);
        menCrearUsuar.setVisible(false);
        menRoles.setVisible(false);
        menAsignarRol.setVisible(false);
    //    this.getSessionBean1().rolesDataProvider.cursorFirst();
        while(iter.hasNext()){
        int keyrol= Integer.parseInt(iter.next().toString());
                switch(keyrol) {
         case 1:
             menRegAct.setVisible(true);
             break;
         case 2:
             menAsign.setVisible(true);
             break;
         case 3:
            menDevol.setVisible(true);
             break;
         case 4:
             menBaja.setVisible(true);
             break;
         case 5:
             menRevaluo.setVisible(true);
         case 6:
             menEncargados.setVisible(true);
             break;
         case 7:
             menActualiz.setVisible(true);
             break;
         case 8:
             menUfv.setVisible(true);
             break;
         case 9:
            menGruposC.setVisible(true);
             break;
         case 10:
             menReportes.setVisible(true);
             break;
         case 11:
             menCrearUsuar.setVisible(true);
             break;
         case 12:
             menRoles.setVisible(true);
             break;
         case 13:
             menAsignarRol.setVisible(true);
             break;
                    default:

             break;
         }
        }
     // }
}catch( Exception ex)
{
System.out.print(ex);
        }
    }
    private CommonTask menUfv = new CommonTask();

    public CommonTask getMenUfv() {
        return menUfv;
    }

    public void setMenUfv(CommonTask ct) {
        this.menUfv = ct;
    }
    private CommonTasksGroup commonTasksGroup1 = new CommonTasksGroup();

    public CommonTasksGroup getCommonTasksGroup1() {
        return commonTasksGroup1;
    }

    public void setCommonTasksGroup1(CommonTasksGroup ctg) {
        this.commonTasksGroup1 = ctg;
    }
    private CommonTask menActualiz = new CommonTask();

    public CommonTask getMenActualiz() {
        return menActualiz;
    }

    public void setMenActualiz(CommonTask ct) {
        this.menActualiz = ct;
    }
    private CommonTask menGruposC = new CommonTask();

    public CommonTask getMenGruposC() {
        return menGruposC;
    }

    public void setMenGruposC(CommonTask ct) {
        this.menGruposC = ct;
    }
    private CommonTask menRegAct = new CommonTask();

    public CommonTask getMenRegAct() {
        return menRegAct;
    }

    public void setMenRegAct(CommonTask ct) {
        this.menRegAct = ct;
    }
    private CommonTask menAsign = new CommonTask();

    public CommonTask getMenAsign() {
        return menAsign;
    }

    public void setMenAsign(CommonTask ct) {
        this.menAsign = ct;
    }
    private CommonTask menDevol = new CommonTask();

    public CommonTask getMenDevol() {
        return menDevol;
    }

    public void setMenDevol(CommonTask ct) {
        this.menDevol = ct;
    }
    private CommonTask menBaja = new CommonTask();

    public CommonTask getMenBaja() {
        return menBaja;
    }

    public void setMenBaja(CommonTask ct) {
        this.menBaja = ct;
    }
    private CommonTask menRevaluo = new CommonTask();

    public CommonTask getMenRevaluo() {
        return menRevaluo;
    }

    public void setMenRevaluo(CommonTask ct) {
        this.menRevaluo = ct;
    }
    private CommonTask menEncargados = new CommonTask();

    public CommonTask getMenEncargados() {
        return menEncargados;
    }

    public void setMenEncargados(CommonTask ct) {
        this.menEncargados = ct;
    }
    private CommonTask menReportes = new CommonTask();

    public CommonTask getMenReportes() {
        return menReportes;
    }

    public void setMenReportes(CommonTask ct) {
        this.menReportes = ct;
    }
    private CommonTask menCrearUsuar = new CommonTask();

    public CommonTask getMenCrearUsuar() {
        return menCrearUsuar;
    }

    public void setMenCrearUsuar(CommonTask ct) {
        this.menCrearUsuar = ct;
    }
    private CommonTask menRoles = new CommonTask();

    public CommonTask getMenRoles() {
        return menRoles;
    }

    public void setMenRoles(CommonTask ct) {
        this.menRoles = ct;
    }
    private CommonTask menAsignarRol = new CommonTask();

    public CommonTask getMenAsignarRol() {
        return menAsignarRol;
    }

    public void setMenAsignarRol(CommonTask ct) {
        this.menAsignarRol = ct;
    }
    // </editor-fold>

    private Boolean logueo;

    public menu() {
       
        }
private CachedRowSetDataProvider ufvDataProvider = new CachedRowSetDataProvider();

    public CachedRowSetDataProvider getUfvDataProvider() {
        return ufvDataProvider;
    }

    public void setUfvDataProvider(CachedRowSetDataProvider crsdp) {
        this.ufvDataProvider = crsdp;
    }
    /**
     * <p>Callback method that is called whenever a page containing
     * this page fragment is navigated to, either directly via a URL,
     * or indirectly via page navigation.  Override this method to acquire
     * resources that will be needed for event handlers and lifecycle methods.</p>
     * 
     * <p>The default implementation does nothing.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here
       // this.getSessionBean1().setUfvUsuario(false);

       

        // <editor-fold defaultstate="collapsed" desc="Visual-Web-managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("Page1 Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
        }
        
        // </editor-fold>
        // Perform application initialization that must complete
        // *after* managed components are initialized
        // TODO - add your own initialization code here
    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called.  Override this
     * method to release resources acquired in the <code>init()</code>
     * resources that will be needed for event handlers and lifecycle methods.</p>
     * 
     * <p>The default implementation does nothing.</p>
     */
    @Override
    public void destroy() {
    }
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }
    public void hyperlink2_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
         try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/menup.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
       // return null;
    }

    public void lkinicio_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //return "case2";
                    try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/menup.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void lkufv_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //return "ufv";
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/ufv.jsp" );

            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void lkgestion_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        //return "gruposc";
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/gestion.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void lkRegactivos_action() {
        // TODO: Replace with your code
        //return null;
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/RegActivos.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void lkAct_deprec_action() {
        // TODO: Replace with your code
        //return null;
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/depreciaciones.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void lkAsignar_action() {
        // TODO: Replace with your code
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/asignacion.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void  lkDevolucion_action() {
        // TODO: Replace with your code
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/devolucion.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void  lkDarBaja_action() {
        // TODO: Replace with your code

       try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/darBaja.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void lkcontable_action() {
        // TODO: Replace with your code
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/GruposContables.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }

    }
public void  lkCrearUsuario_action() {
        // TODO: Replace with your code

       try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/crearUsuario.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

public void  lkAsignarUSuario_action() {
        // TODO: Replace with your code

       try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/asignar_roles.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

public void  lkCrearRoles_action() {
        // TODO: Replace with your code

       try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/crearRoles.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public String treeNode1_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return null;
    }

    public String treeNode3_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return null;
    }

    public void menActualiz_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/depreciaciones.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menInicio_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
         try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/menup.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menReportes_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/reportes.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menUfv_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
         try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/ufv.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menGruposC_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/GruposContables.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menRegAct_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
       try{
                        int keysec=getSessionBean1().getSeccion();
                        //this.getSessionBean1().getActivo_registroRowSet1().setCommand("SELECT * FROM ACTIVOS.ACTIVO where keyseccion=? order by fecha_ingreso desc");
                        //this.getSessionBean1().getActivo_registroRowSet1().setInt(1, keysec);
                        switch(keysec)
                        {
                            case 1:
                                FacesContext contex = FacesContext.getCurrentInstance();
                                contex.getExternalContext().redirect( "/SistemaBienes/faces/RegActivos.jsp" );
                                break;
                            case 2:
                                FacesContext contex1 = FacesContext.getCurrentInstance();
                                contex1.getExternalContext().redirect( "/SistemaBienes/faces/RegActivos_1.jsp" );
                                break;
                            case 3:
                                FacesContext contex2 = FacesContext.getCurrentInstance();
                                contex2.getExternalContext().redirect( "/SistemaBienes/faces/RegActivos_2.jsp" );
                                break;
                            default:
                                System.out.println("El mes no existe");
                                break;
                        }
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menAsign_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/asignacion.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menDevol_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/devolucion.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menBaja_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/darBaja.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menRevaluo_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/revaluoTecnico.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menEncargados_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/RegPersona.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    public void menCrearUsuar_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/crearUsuario.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }

    }

    public void menRoles_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/crearRoles.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }

    }

    public void menAsignarRol_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
         try{
                        FacesContext contex = FacesContext.getCurrentInstance();
                        contex.getExternalContext().redirect( "/SistemaBienes/faces/asignar_roles.jsp" );
            }catch(  Exception e ){
             error( " no funciona esta redireccion" );
                }
    }

    /**
     * @return the logueo
     */
    public Boolean getLogueo() {
        return logueo;
    }

    /**
     * @param logueo the logueo to set
     */
    public void setLogueo(Boolean logueo) {
        this.logueo = logueo;
    }


}
